<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div class="searchBar">
    名称：
    <div class="layui-inline">
        <input class="layui-input" name="name" id="name" autocomplete="off" />
    </div>
    <button class="layui-btn" id="searchBtn" data-type="reload">搜索</button>
</div>
<!--表格主体-->
<table id="role" lay-filter="role"></table>
<!--工具栏 toolbar-->
<div id="toolbar" style="display: none;">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm" lay-event="add">新增</button>
    </div>
</div>
<!--操作栏 tool-->
<script type="text/html" id="operateBar">
    <a class="layui-btn layui-btn-sm" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除
    </a>
</script>

<table id="demo"></table>
<script src="/layui/layui.js"></script>
<script>
    layui.use(['table','layer', 'form', 'jquery'], function(){
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        table.render({
            elem: '#role'
            ,height: 525
            ,id:'testReload'
            ,url: '/api/role/page' //数据接口
            ,page: true //开启分页
            ,cols: [[ //表头
                {field: 'id', title: 'ID', sort: true, fixed: 'left'}
                ,{field: 'role_sort', title: '显示顺序'}
                ,{field: 'role', title: '角色标识'}
                ,{field: 'remark', title: '备注'}
                ,{field: 'status', title: '角色状态'}
                ,{field: 'del_flag', title: '删除标志'}
                ,{field: 'create_datetime', title: '创建时间', sort: true, templet: "<div>{{layui.util.toDateString(d.create_datetime, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                ,{title: '操作', toolbar:'#operateBar', align:'center'}
            ]]
            ,toolbar: '#toolbar'
            ,response : {
                statusCode : 1
            }
            ,parseData : function (res) {
                if (res.status == 1) {
                    return {
                        'code' : res.status,
                        'msg' : res.message,
                        'count' : res.total,
                        'data' : res.data
                    }
                }
            }
        });
    });

</script>
</body>
</html>